package com.mlf.prototype.demo;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class Person {
    String name;
    Person(String name) { this.name = name; }

    public static void main(String[] args) {
        List<Person> original = new ArrayList<>();
        original.add(new Person("Alice"));

        // 浅拷贝
        List<Person> copy = new ArrayList<>(original);

        // 修改副本中的 Person 对象
        copy.get(0).name = "Bob";

        System.out.println(original.get(0).name); // 输出 "Bob"（原数据被修改！）

        List<String> strs = new ArrayList<>();
        strs.add("hello");

        List<String> strings = new ArrayList<>(strs);
        strings.set(0, "world");
        System.out.println(strs.get(0));

    }
}

